/**
 * 操作权限处理
 * @param { string | string[]} permission 权限数据
 */
export function hasPermi(permission: string | string[]) {
    const all_permission = '*:*:*';
    const permissions = $store.user.permissions;
    if (permission) {
        if (typeof permission === 'string') {
            permission = [permission]
        }
        return permissions.some((v: string) => all_permission === v || permission.includes(v));
    } else {
        throw new Error(`请设置操作权限标签值`);
    }
}

/**
 * 角色权限处理
 * @param { string | string[]} permission 权限数据
 */
export function hasRole(role: string | string[]) {
    const roles = $store.user.roles;

    if (role) {
        if (typeof role === 'string') {
            role = [role]
        }
        return roles.some((v: string) => role.includes(v));
    } else {
        throw new Error(`请设置角色权限标签值`);
    }
}